/*************************************************************************
	> File Name: oj-443_count_trees.c
	> Author: Wang Bo
	> Mail: 1276106221@qq.com
	> Created Time: 2020年10月19日 星期一 13时54分18秒
 ************************************************************************/

#include <stdio.h>
#include <stdlib.h>

void rm_tree(int *data, int x, int y) {
    for (int i = x; i <= y; ++i) {
        data[i] = 0;
    }
}

int count(int *data, int len) {
    int ret = 0;
    for (int i = 0; i < len; ++i) {
        ret += data[i];
    }
    return ret;
}

int main() {
    int l, m, a, b;
    scanf("%d%d", &l, &m);
    int *road = (int *)malloc(sizeof(int) * (l + 1));
    for (int i = 0; i < l + 1; ++i) {
        road[i] = 1;
    }
    for (int i = 0; i < m; ++i) {
        scanf("%d%d", &a, &b);
        rm_tree(road, a, b);
    }
    printf("%d", count(road, l + 1));
    free(road);
    return 0;
}
